package com.credithc.customers.dataservice.mapper.HYR;

import com.credithc.customers.dataservice.po.*;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface HyrMapper {
    @Select("SELECT id , usertype userType ,usrcustid accountNo from user where id = #{value}")
    HyrUserInfoPo queryHyrUserInfo(String value);
    @Select("select id,preCustomerNo,customerNo from hyr_user_message where id = #{value};")
    CustomerNoPo getByUserId(String value);

    @Select("select title productName,id,id incrementId ,creat_time creatTime  from dtpay\n" +
            "where id< #{incrementId} and id >= #{incrementId } - 10000 ORDER BY id desc ; ")
    List<SystemProductPo> queryHyrProduct(@Param("incrementId")String incrementId);
    @Select("select MAX(id)  from dtpay\n ")
    Long queryProductMaxId();

    @Select("select user.usrcustid customerId ,hyr_user_message.customerNo customerNo,user.usertype userType ,hyr_user_message.id incrementId,hyr_user_message.id userId ,user.add_time creatTime\n" +

            "from hyr_user_message LEFT JOIN user on hyr_user_message.id = user.id \n" +
            "where hyr_user_message.id < #{incrementId} and hyr_user_message.id >=  #{incrementId} -10000  ORDER BY hyr_user_message.id desc")
    List<SystemUserPo>queryHyrUser(@Param("incrementId")String incrementId);
    @Select("select MAX(id)  from hyr_user_message\n ")
    Long queryUserMaxId();

    @Select("select  hyr_user_message.customerNo customerNo ,userbank.uid userId,userbank.id incrementId ,userbank.cardid customerId ,userbank.addtime creatTime \n" +
            " from userbank LEFT JOIN hyr_user_message on userbank.uid =hyr_user_message.id \n" +
            " where userbank.id < #{toString} and userbank.id >= #{toString} - 10000 ORDER BY userbank.id desc ")
    List<SystemUserPo> queryHyrBankCard(@Param("toString") String toString);
    @Select("select MAX(id)  from userbank\n ")
    Long queryBanckMaxId();

 /*   @Select("select uid userId, dtbid productId, term period,money amount,addtime capitalEffectDate ,duetime  expireDate ,status sts ,id incrementId\n" +
            " from orderfixinvest where id< #{incrementId} and  id >=  #{incrementId} - 1000\n " +
            " ORDER BY id desc;")
    List<SystemLendPo>queryHyrFixLend(@Param("incrementId")String incrementId);
    @Select("select MAX(id)  from orderfixinvest\n ")
    Long queryFixMaxId();
    @Select("select uid userId, dtbid productId, term period,money amount,throw_time capitalEffectDate ,endtime  expireDate ,status sts ,id incrementId\n" +
            " from hyr_throw_new where id< #{incrementId} and id >= #{incrementId} -1000 \n" +
            " ORDER BY id desc;")
    List<SystemLendPo>queryHyrThrowLend(@Param("incrementId")String incrementId);
    @Select("select MAX(id)  from hyr_throw_new\n ")
    Long queryThrowMaxId();
    @Select("select uid userId, dtbid productId, orderterm period,money amount,addtime capitalEffectDate ,duetime  expireDate ,status sts ,id incrementId\n" +
            " from ordercright where id< #{incrementId} and id >= #{incrementId}-1000 \n" +
            " ORDER BY id desc;")
    List<SystemLendPo>queryHyrCrightLend(@Param("incrementId")String incrementId);
    @Select("select MAX(id)  from ordercright\n ")
    Long queryCrightMaxId();*/


    @Select("select uid userId, dtbid productId, term period,money amount,addtime capitalEffectDate ,duetime  expireDate ,status sts ,id incrementId\n" +
            "             from orderfixinvest where crmid = #{crmid} ")
    SystemLendPo selectfixCP(String crmid);
    @Select(" select uid userId, dtbid productId, term period,money amount,throw_time capitalEffectDate ,endtime  expireDate ,status sts ,id incrementId \n" +
            "             from hyr_throw_new where crmid =#{crmid}")
    SystemLendPo selectThrowCP(String crmid);
    @Select("select uid userId, dtbid productId, orderterm period,money amount,addtime capitalEffectDate ,duetime  expireDate ,status sts ,id incrementId \n" +
            "             from ordercright where crmid =#{crmid}")
    SystemLendPo selectOrderCP(String crmid);
    @Select("SELECT id, dtbtype dtbType , crmid,`status` from lenduinfo where crmlc_times = 1 and  id< #{toString}  and  id >=  #{toString} -10000 " +
            "            ORDER BY id desc;")
    List<HyrOrderPo> querylend(String toString);
    @Select("select MAX(id)  from lenduinfo;")
    Long querylendMaxId();
}
